// 导入自定义的异步请求
import request from '@/utils/request';

/**
 * 文章模块业务
 */
export default {

  // 1: 查询文章搜索并分页
  findArticlePage(articleVo = {pageNo: 1, pageSize: 10}) {
    return request.post("article/list", articleVo);
  },

  // 2: 保存文章
  saveUpdateArticle(article = {}) {
    return request.post("article/saveupdate", article);
  },

  // 3: 根据id删除文章
  delArticle(id) {
    if (!id) {
      return;
    }
    return request.post("article/del/" + id);
  },

  // 4: 批量删除
  delBatchArticle(batchIds) {
    if (!batchIds) {
      return;
    }
    return request.post("article/delBatch", {batchIds});
  },

  // 5: 根据id查询文章明细
  getArticle(id) {
    if (!id) {
      return;
    }
    return request.get("article/get/" + id);
  },

  //查询热点文章
  findArticleTop(articleVo = {pageNo: 1, pageSize: 10}){
    return request.post("article/getTop",articleVo );
  },

  //文章点赞
  articleZanPlus(articleid){
    return request.post( `/api/article/zan/like/${articleid}` );
  },

  //文章取消点赞
  articleZanMius(articleid){
    return request.post( `/api/article/zan/unlike/${articleid}` );
  },
  //文章收藏
  articleCollectPlus(articleid){
    return request.post( `/api/article/collect/like/${articleid}` );
  },
  //文章取消收藏
  articleCollectMius(articleid){
    return request.post( `/api/article/collect/unlike/${articleid}` );
  },

  // 查询自己的文章
  findArticleMy(articleVo = {}) {
    return request.post("/api/article/listmy", articleVo);
  },
}
